package com.echat.serviceapigateway.zuul.controller;

import com.echat.serviceapigateway.security.common.HttpResult;
import com.echat.serviceapigateway.zuul.service.GatewayRefreshService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chenmohan on 2018/10/16
 *
 * @description
 */
@RestController
@RequestMapping(value = "/gateway",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class GatewayController {

    @Autowired
    GatewayRefreshService refreshService;

    @GetMapping("/refresh")
    public HttpResult<Void> refresh() {
        refreshService.refresh();
        return HttpResult.success();
    }

    @GetMapping("/list")
    public HttpResult<List> routeList() {
        return HttpResult.success(refreshService.routeList());
    }

}
